]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
brightness: Ignore slider changes we initiated ourselves
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 12 Aug 2019 12:10:43 +0000 (14:10 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 13 Aug 2019 14:35:17 +0000 (16:35 +0200)
Since we set the proxy value when the slider changes and set the slider
value on proxy property changes, we run into a cycle.

Before commit 3d3dca4aa this was addressed by not notifying on all slider
changes, but only in reaction to direct user action. Given that since the
splitting out of the BarLevel class those events are handled in a subclass,
that approach is at least unconvential and fairly fragile.

Instead, make the brightness indicator ignore any changes to the slider it
initiated itself.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1500

js/ui/status/brightness.js

index 16c1e9dbb56cc77ddf4662cafca4061801409322..662b39a8602b4442d1172f9d700eb2efa462232e 100644 (file)
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported Indicator */
 
-const { Gio, St } = imports.gi;
+const { Gio, GObject, St } = imports.gi;
 
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
@@ -33,7 +33,8 @@ var Indicator = class extends PanelMenu.SystemIndicator {
         this.menu.addMenuItem(this._item);
 
         this._slider = new Slider.Slider(0);
-        this._slider.connect('notify::value', this._sliderChanged.bind(this));
+        this._sliderChangedId = this._slider.connect('notify::value',
+            this._sliderChanged.bind(this));
         this._slider.accessible_name = _("Brightness");
 
         let icon = new St.Icon({ icon_name: 'display-brightness-symbolic',
@@ -54,10 +55,16 @@ var Indicator = class extends PanelMenu.SystemIndicator {
         this._proxy.Brightness = percent;
     }
 
+    _changeSlider(value) {
+        GObject.signal_handler_block(this._slider, this._sliderChangedId);
+        this._slider.value = value;
+        GObject.signal_handler_unblock(this._slider, this._sliderChangedId);
+    }
+
     _sync() {
         let visible = this._proxy.Brightness >= 0;
         this._item.visible = visible;
         if (visible)
-            this._slider.value = this._proxy.Brightness / 100.0;
+            this._changeSlider(this._proxy.Brightness / 100.0);
     }
 };